import { Message } from 'element-ui'

const rmessage = (option) => {
  Message.closeAll()
  Message(option)
}

['error', 'success', 'info', 'warning'].forEach(type => {
  rmessage[type] = options => {
    if (typeof options === 'string') {
      options = {
        message: options
      }
    }
    options.type = type
    return rmessage(options)
  }
})

export default rmessage
